// 首页
class HomePage extends JPanel {
    public HomePage(PhoneRecycleApp app) {
        setLayout(new BorderLayout());
        setBackground(new Color(245, 245, 245));
        
        // 顶部导航栏
        JPanel header = new JPanel(new BorderLayout());
        header.setBackground(new Color(255, 69, 0));
        header.setPreferredSize(new Dimension(400, 50));
        
        // 位置信息
        JLabel locationLabel = new JLabel(" 沈阳");
        locationLabel.setFont(new Font("Microsoft YaHei", Font.BOLD, 12));
        locationLabel.setForeground(Color.WHITE);
        header.add(locationLabel, BorderLayout.WEST);
        
        // 搜索框
        JPanel searchPanel = new JPanel(new BorderLayout());
        searchPanel.setBackground(Color.WHITE);
        searchPanel.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10));
        
        JLabel searchLabel = new JLabel("🔍 搜索商品");
        searchLabel.setFont(new Font("Microsoft YaHei", Font.PLAIN, 10));
        searchLabel.setForeground(new Color(153, 153, 153));
        searchPanel.add(searchLabel, BorderLayout.WEST);
        
        header.add(searchPanel, BorderLayout.CENTER);
        
        // 消息图标
        JLabel messageLabel = new JLabel("✉");
        messageLabel.setFont(new Font("Arial", Font.PLAIN, 14));
        messageLabel.setForeground(Color.WHITE);
        header.add(messageLabel, BorderLayout.EAST);
        
        add(header, BorderLayout.NORTH);
        
        // 限时力区域
        JPanel promoHeader = new JPanel(new FlowLayout(FlowLayout.LEFT));
        promoHeader.setBackground(new Color(255, 109, 0));
        promoHeader.setPreferredSize(new Dimension(400, 40));
        
        JLabel promoLabel = new JLabel("限时力");
        promoLabel.setFont(new Font("Microsoft YaHei", Font.BOLD, 12));
        promoLabel.setForeground(Color.WHITE);
        promoHeader.add(promoLabel);
        
        add(promoHeader, BorderLayout.CENTER);
        
        // 内容面板
        JPanel contentPanel = new JPanel();
        contentPanel.setLayout(new BoxLayout(contentPanel, BoxLayout.Y_AXIS));
        contentPanel.setBackground(new Color(245, 245, 245));
        contentPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
        
        // 手机数码分类
        JPanel categoryPanel = PhoneRecycleApp.createCardPanel("手机数码");
        
        JPanel categoriesPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 10, 5));
        categoriesPanel.setBackground(Color.WHITE);
        
        String[] categories = {"手机", "电脑", "耳机", "手表"};
        for (String category : categories) {
            JLabel catLabel = new JLabel(category);
            catLabel.setFont(new Font("Microsoft YaHei", Font.PLAIN, 12));
            categoriesPanel.add(catLabel);
        }
        
        categoryPanel.add(categoriesPanel);
        contentPanel.add(categoryPanel);
        contentPanel.add(Box.createVerticalStrut(10));
        
        // 新用户专享区域
        JPanel newUserPanel = PhoneRecycleApp.createCardPanel("新用户专享");
        newUserPanel.setBackground(new Color(255, 243, 224));
        
        JLabel discountLabel = new JLabel("限时加价18%");
        discountLabel.setFont(new Font("Microsoft YaHei", Font.PLAIN, 12));
        discountLabel.setForeground(new Color(255, 109, 0));
        discountLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
        newUserPanel.add(discountLabel);
        
        JPanel devicePanel = new JPanel();
        devicePanel.setLayout(new BoxLayout(devicePanel, BoxLayout.X_AXIS));
        devicePanel.setBackground(new Color(255, 243, 224));
        devicePanel.setAlignmentX(Component.LEFT_ALIGNMENT);
        
        JLabel deviceLabel = new JLabel("vivo IQOO 11 Pro | 更换");
        deviceLabel.setFont(new Font("Microsoft YaHei", Font.PLAIN, 12));
        
        JLabel priceLabel = new JLabel("预估￥1519");
        priceLabel.setFont(new Font("Microsoft YaHei", Font.BOLD, 14));
        priceLabel.setForeground(new Color(255, 69, 0));
        
        devicePanel.add(deviceLabel);
        devicePanel.add(Box.createHorizontalGlue());
        devicePanel.add(priceLabel);
        
        newUserPanel.add(devicePanel);
        
        // 立即换钱按钮
        JButton changeButton = new JButton("立即换钱");
        changeButton.setFont(new Font("Microsoft YaHei", Font.BOLD, 14));
        changeButton.setBackground(new Color(255, 69, 0));
        changeButton.setForeground(Color.WHITE);
        changeButton.setBorderPainted(false);
        changeButton.setFocusPainted(false);
        changeButton.setAlignmentX(Component.LEFT_ALIGNMENT);
        changeButton.addActionListener(e -> app.showPage(PhoneRecycleApp.VALUATION_PAGE));
        
        newUserPanel.add(Box.createVerticalStrut(10));
        newUserPanel.add(changeButton);
        
        contentPanel.add(newUserPanel);
        contentPanel.add(Box.createVerticalStrut(10));
        
        // 回收方式区域
        JPanel recyclePanel = PhoneRecycleApp.createCardPanel("3招帮你卖 怎么都省心");
        
        String[] methods = {"门店回收", "上门回收", "邮寄回收"};
        for (String method : methods) {
            JLabel methodLabel = new JLabel("• " + method);
            methodLabel.setFont(new Font("Microsoft YaHei", Font.PLAIN, 12));
            methodLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
            recyclePanel.add(methodLabel);
        }
        
        contentPanel.add(recyclePanel);
        
        JScrollPane scrollPane = new JScrollPane(contentPanel);
        scrollPane.setBorder(BorderFactory.createEmptyBorder());
        add(scrollPane, BorderLayout.CENTER);
        
        // 底部导航
        JPanel navbarPanel = new JPanel(new GridLayout(1, 5));
        navbarPanel.setBackground(Color.WHITE);
        navbarPanel.setPreferredSize(new Dimension(400, 50));
        
        String[] navItems = {"首页", "领券", "换钱", "回收车", "我的"};
        String[] navIcons = {"🏠", "🎫", "💰", "🛒", "👤"};
        
        for (int i = 0; i < navItems.length; i++) {
            JPanel navPanel = new JPanel();
            navPanel.setLayout(new BoxLayout(navPanel, BoxLayout.Y_AXIS));
            navPanel.setBackground(Color.WHITE);
            
            JLabel iconLabel = new JLabel(navIcons[i], SwingConstants.CENTER);
            iconLabel.setFont(new Font("Arial", Font.PLAIN, 16));
            iconLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
            
            JLabel textLabel = new JLabel(navItems[i], SwingConstants.CENTER);
            textLabel.setFont(new Font("Microsoft YaHei", Font.PLAIN, 9));
            textLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
            
            navPanel.add(iconLabel);
            navPanel.add(textLabel);
            
            if (i == 0) { // 首页高亮
                JLabel dotLabel = new JLabel("•", SwingConstants.CENTER);
                dotLabel.setFont(new Font("Arial", Font.PLAIN, 16));
                dotLabel.setForeground(new Color(255, 69, 0));
                dotLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
                navPanel.add(dotLabel);
            }
            
            navbarPanel.add(navPanel);
        }
        
        add(navbarPanel, BorderLayout.SOUTH);
    }
}
